package com.klxedu.ms.gateway.security.authentication.impl;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import com.klxedu.ms.gateway.security.authentication.IAuthenticateAction;
import com.klxedu.ms.gateway.security.authentication.IAuthenticatedUser;

public class MockWXAuthenticateAction implements IAuthenticateAction {

	@Override
	public IAuthenticatedUser doAuthenticate(String userName) throws AuthenticationException {
		if (!userName.equals("wx")) {
			throw new UsernameNotFoundException("用户不存在: " + userName);
		}
		BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
		return new AuthenticatedUserImpl("wx", "gr", encoder.encode("wx"));
	}
}
